/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assisisw.smartcal.webuisubsystem.managedbean;

import assisisw.smartcal.entitysubsystem.User;
import assisisw.smartcal.securitysubsystem.PasswordManager;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import org.primefaces.context.RequestContext;

/**
 *
 * @author Francesco
 */
public abstract class AbstractUserAnagraphicsViewBean implements Serializable 
{
    // Instance Fields
   
    /***/
    private PasswordManager passwordManager ;
    
    /***/
    private User userSigningUp ;
   
    // Instance Methods
    
    /***/
    protected AbstractUserAnagraphicsViewBean (){}
    
    /**
     * @return
     */
    public abstract String submitUserAnagraphicForm ();
    
    /***/
    @PostConstruct 
    public void init () 
    {
        passwordManager = new PasswordManager () ;
        userSigningUp = new User () ;
    }
    
    /**
     * AS THE SUPER'S ONE.
     */
    public User getUserSigningUp ()  
    {
        return userSigningUp ;
    }
    
    public void checkPassword () 
    {
        PasswordManager.PasswordEvaluationResult res ;
            res = passwordManager.evaluate ( userSigningUp.getPassword () ) ;
        FacesContext.getCurrentInstance().addMessage ( null , new FacesMessage ( "The password is" , res.toString() + " !" ) ) ;
    }
    
    protected void setUserSigningUp ( User userSigningUp ) 
    {
        this.userSigningUp = userSigningUp ;
    }
    
}
